﻿/***************************************************************************************
   Date    : January 30, 2006
   Purpose : Implement the BowlerInfo Class
   Maintenance Log : 
   Revision		Date			Description 
   --------		----		------------------------------------------------------
	1.0		 07/02/2008		    Initial Release

****************************************************************************************/
using System;

namespace Hclt.Msft.Til.CricketScoreboard
{
  
    /// <summary>
    /// BowlerInfo class contains all information 
    /// related to a bowler 
 
    /// </summary>

    public class BowlerInfo
    {
        //Variable declaration
        private string bowlerName;
        private int totalBalls;
        private int totalRuns;
        private int totalWickets;
        private BowlerStatus status;  //status of bowler active or inactive      

        
        /// <summary>
        /// Gets or Sets bowler name
        /// </summary>
        public string BowlerName
        {
            get
            {
                return bowlerName;
            }
            set
            {
                bowlerName = value;
            }
        }

        /// <summary>
        /// Gets or Sets total balls that bowler has done
        /// </summary>
        public int TotalBalls
        {
            get
            {
                return totalBalls;
            }
            set
            {
                totalBalls = value;
            }
        }

       
        /// <summary>
        /// gets or set total run given by a bowler
        /// </summary>
        public int TotalRuns
        {
            get
            {
                return totalRuns;
            }
            set
            {
                totalRuns = value;
            }
        }

        /// <summary>
        /// Gets or set total wicket bowler has taken
        /// </summary>
        public int TotalWickets
        {
            get
            {
                return totalWickets;
            }
            set
            {
                totalWickets = value;
            }
        }

        /// <summary>
        /// Gets or set status of bowler active or inactive
        /// </summary>
        public BowlerStatus Status
        {
            get
            {
                return status;
            }
            set
            {
                status = value;
            }
        }

       /// <summary>
       ///Calculates total overs done by a bowler
       /// </summary>
        public string TotalOvers
        {
            get
            {
                return string.Concat(Convert.ToInt32(totalBalls / 6), "." , (totalBalls % 6));
            }
        }


        /// <summary>
        /// calculates RPO of a bowler that is run given in a over
        /// </summary>
        public string RunsPerOver
        {
            get
            {
                string returnValue = string.Empty;
                if (totalBalls > 0)
                {
                    double runsPerOver = ((Convert.ToDouble(totalRuns) / Convert.ToDouble(totalBalls)) * 6);
                    returnValue = Convert.ToString(Math.Round(runsPerOver,2));
                }
                return returnValue;
            }
        }
    }
}
